home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
man
/
cat.3
/
ftw.3
< prev
next >
Wrap
Text File
|
1995-07-27
|
4KB
|
133 lines
FFFFTTTTWWWW((((3333)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV FFFFTTTTWWWW((((3333))))
NNNNAAAAMMMMEEEE
ftw - walk a file tree
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
####iiiinnnncccclllluuuuddddeeee <<<<ffffttttwwww....hhhh>>>>
iiiinnnntttt
ffffttttwwww((((ddddiiiirrrreeeeccccttttoooorrrryyyy,,,, ffffuuuunnnnccccppppttttrrrr,,,, ddddeeeepppptttthhhh))))
cccchhhhaaaarrrr ****ddddiiiirrrreeeeccccttttoooorrrryyyy;;;;
iiiinnnntttt ((((****ffffuuuunnnnccccppppttttrrrr))))(((())));;;;
iiiinnnntttt ddddeeeepppptttthhhh;;;;
####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ssssttttaaaatttt....hhhh>>>>
iiiinnnntttt
ffffuuuunnnnccccppppttttrrrr((((iiiitttteeeemmmm,,,, ssssbbbb,,,, ffffllllaaaagggg))))
cccchhhhaaaarrrr ****iiiitttteeeemmmm;;;;
ssssttttrrrruuuucccctttt ssssttttaaaatttt ****ssssbbbb;;;;
iiiinnnntttt ffffllllaaaagggg;;;;
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
_F_t_w walks through the directory tree starting from the
indicated _p_a_t_h. For every entry it finds in the tree, it
calls the user-supplied _f_u_n_c_p_t_r with the calling sequence
given in the synopsis above. The first argument is the full
pathname of the entry (rooted from the _d_i_r_e_c_t_o_r_y parameter
given to _f_t_w); the second argument is a pointer to the
_s_t_a_t(2) structure for the entry; and the third argument is
one of the #define's in the header file. This value will be
one of the following:
FTW_F Item is a normal file
FTW_D Item is a directory
FTW_NS The stat failed on the item
FTW_DNR Item is a directory which can't be read
Note, however, that FTW_F is a misnomer; anything other than
directories are (e.g., symbolic links) get the FTW_F tag.
_F_t_w recursively calls itself when it encounters a directory.
To avoid using up all a program's file descriptors, the
_d_e_p_t_h argument specifies the number of simultaneous open
directories to maintain. When the depth is exceeded, the
routine will become noticeably slower because directories
are closed in ``most-recently-used'' order.
To stop the tree walk, the user-supplied function should
return a non-zero value; this value will become the return
value of _f_t_w. Otherwise, _f_t_w will continue until it has
scanned the entire tree, in which case it will return zero,
or until it hits an error such as a _m_a_l_l_o_c(3) failure, in
which case it will return -1.
Because _f_t_w uses dynamic data structures, the only safe way
Page 1 (printed 7/27/95)
FFFFTTTTWWWW((((3333)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV FFFFTTTTWWWW((((3333))))
to exit out of a tree walk is to return a non-zero value.
To handle interrupts, for example, mark that the interrupt
occured and return a non-zero value- don't use _l_o_n_g_j_m_p (_3)
unless the program is going to terminate.
SSSSEEEEEEEE AAAALLLLSSSSOOOO
stat(2)
Page 2 (printed 7/27/95)